package cn.dkdoo.redis;

import cn.dkdoo.redis.config.RedisConfig;
import cn.dkdoo.redis.config.RedisKeys;
import cn.dkdoo.utils.templateDefault.redis.DefaultRedisTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;

/**
 * Created by Nicky.Tang on 2021/5/16 6:00 下午
 *
 * @since 02.12.10
 */
public class RedisConsume {
    private static final Logger logger = LoggerFactory.getLogger(RedisConsume.class);
    @Resource(name = RedisConfig.defaultRedisTemplate)
    private DefaultRedisTemplate defaultRedisTemplate;

    @Scheduled(fixedDelay = 100)
    public void doConsume() {
        String res = defaultRedisTemplate.opsForList().leftPop(RedisKeys.DEMO_TEST_TRANSACTIONAL);
        if (res != null) {
            logger.info("doConsume: " + res);
        }
    }
}
